<?php
class Somi_Form_BewerbenForm extends Zend_Dojo_Form
{
	public function init()
	{
		
		$this->setName('Bewerben');
		$this->setAction($this->getView()->url())->setMethod('post');
		$this->addAttribs(array('onSubmit'=>'return validate(this)'));
		
		require_once APPLICATION_HTDOCS.'/library/Somi/Validate/ErrorMessageDe.php';
		
		$translateValidators= new Somi_Validate_ErrorMessageDe();
		$translator = new Zend_Translate('array', $translateValidators->getTranslate());
    	Zend_Validate_Abstract::setDefaultTranslator($translator);
    	
    	#$this->clearDecorators();
		$formDecorators=array(
            'FormElements',
        array('HtmlTag',array('tag'=>'dl','class'=>'zend_form')),
            'DijitForm', // hier stand bei dir vorher: 'Form',
        );
                
        
        $elementDecorators=array(
        'DijitElement', // vorher: 'ViewHelper',
        'Errors',
        array(array('data'=>'HtmlTag'),array('tag'=>'div','class'=>'element')),
        array('Label',array('class'=>'left','requiredSuffix' => '*')),
        array(array('row'=>'HtmlTag'),array('tag'=>'div','class'=>'row')),
        );
        
        $buttonDecorators=array(
        'DijitElement', // vorher: 'ViewHelper',
        array(array('data'=>'HtmlTag'),array('tag'=>'div','class'=>'button')),
        array(array('row'=>'HtmlTag'),array('tag'=>'div'))
        );  
		
	
		$filterToLower = new Zend_Filter_StringToLower();
        $filterToLower->setEncoding('UTF-8');
        
	     
	     
        
	    #Anrede
        $anrede = $this->createElement('FilteringSelect','anrede',array(
		'label'        => 'Anrede',
        #'value'        => '',
        'autocomplete' => false,
        'style'			=> 'width:245px;',
        'multiOptions' => array('Frau' => 'Frau','Herr' => 'Herr'),
        ));
        
        #Titel
        $titel=$this->createElement('ValidationTextBox','titel',array(
        'label'			=> 'Titel',
        'alnum'			=>true,
        'required'		=> false,
        'PromptMessage'		=> '<div style="width:200px">z.B. Dr.</div>', 
        'style'			=> 'width:245px;', 
        'filters'		=> array($filterToLower,),
        #'validators'	=> array('NotEmpty',), 
        ));

        
        #Vorname
        $vorname=$this->createElement('ValidationTextBox','vorname',array(
        'label'			=> 'Vorname *',
        'alnum'			=>true,
        'required'		=> true,
        'PromptMessage'		=> '<div style="width:200px">z.B. Max</div>', 
        'style'			=> 'width:245px;', 
        'filters'		=> array($filterToLower,),
        #'validators'	=> array('NotEmpty',), 
        ));
        
        
        #nachname
        $nachname=$this->createElement('ValidationTextBox','nachname',array(
        'label'			=> 'Nachname *',
        'alnum'			=>true,
        'required'		=> true,
        'PromptMessage'		=> '<div style="width:200px">z.B. Müller</div>', 
        'style'			=> 'width:245px;', 
        'filters'		=> array($filterToLower,),
        'validators'	=> array('NotEmpty',), 
        ));
        
        #strasse
        $strasse=$this->createElement('ValidationTextBox','strasse',array(
        'label'			=> 'Straße/Nr.',
        'alnum'			=>true,
        'required'		=> false,
        'PromptMessage'		=> '<div style="width:200px">z.B. Kennedyallee 93 </div>', 
        'style'			=> 'width:245px;', 
        #'filter'		=> $filterToLower, 
        ));
        
        
        #Stadt
        $stadt=$this->createElement('ValidationTextBox','stadt',array(
        'label'			=> 'PLZ/Stadt',
        'alnum'			=>true,
        'required'		=> false,
        'PromptMessage'		=> '<div style="width:200px">z.B. 60596 Frankfurt am Main </div>', 
        'style'			=> 'width:245px;', 
        'filters'		=> array($filterToLower,), 
        ));
        
        
        
		$validateEmail = new Zend_Validate_EmailAddress();
        #Email
        $email=$this->createElement('ValidationTextBox','email',array(
        'label'			=> 'Email *',
        'alnum'			=>true,
        'required'		=> true,
        'PromptMessage'	=> '<div style="width:200px">z.B. inf@somi.de </div>', 
        'style'			=> 'width:245px;', 
        'filters'		=> array($filterToLower,),
        'validators'	=> array('NotEmpty',$validateEmail,),
        #'regExp'			=>'\b[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}\b', 
        ));
        
        
        #Telefon
        $telefon=$this->createElement('ValidationTextBox','telefon',array(
        'label'			=> 'Telefon',
        'alnum'			=>true,
        'required'		=> false,
        'PromptMessage'		=> '<div style="width:200px">z.B.<br> 06957706700 <br> 0049 69 577 06 700 <br> +49 69 577 06 700</div>', 
        'style'			=> 'width:245px;', 
        #'regExp'			=>'\(?[0][0-9]+\)?([-. ]?[0-9])*$~i',
        'regExp'		=> '(^[0+]{1})([ 0-9/()]+$)', 
        'validators'		=> array('NotEmpty'),
        ));
        #$telefon->addValidator('regex',false,array('(^[0+]{1})([ 0-9/()]+$)'));
        
        
		#aufmerksam
		$aufmerksam = $this->createElement('ComboBox','aufmerksam',array(
		'label'			=> 'Woher kennen Sie SOMI',
		'style'			=> 'width:245px;',
		'multiOptions' => array('Bitte wählen Sie' => 'Bitte wählen Sie' ,'Suchmaschine' => 'Suchmaschine','Online-Stellenanzeigen' => 'Online-Stellenanzeigen','Gedruckte Anzeige' =>'Gedruckte Anzeige', 'Arbeitsamt / Arbeitsagentur' => 'Arbeitsamt / Arbeitsagentur', 'Empfehlung' => 'Empfehlung', 'Veranstaltung' => 'Veranstaltung','Aushang an FH, UNI, etc.' => 'Aushang an FH, UNI, etc.'),
		));
        
        
        #Nachricht
		$nachricht=$this->createElement('Textarea','nachricht',array(
		'label'		=> 'Nachricht *',
		#'style'		=>'height:100px;width:300px;',
		#'height'		=>'100px',
		#'PromptMessage'		=> '<div style="width:200px">Noch mher Input</div>',
		'style'    => 'width: 248px; height: 100px;',
		'required'	=> true,
		'validators'	=> array('NotEmpty',),
		));

		
		#file
		$file = $this->createElement('file','file',array(
		'label'	=> 'Anhang (max. 3MB)',
		'description' => 'pdf,doc,docx',
		#'MaxFileSize' 	=> 3*1024*1024,
		));
		$file->addValidator('Size',true, 3*1024*1024);
		$file->addValidator('Extension',true,array('pdf','doc','docx'));
		

        
        
        $submit=$this->createElement('SubmitButton','submit',array(
        'label'			=> 'Senden',
        'style'			=> 'margin-left:345px;',
        ));
        
        
        
        $this->addElements(array($anrede,$titel,$vorname,$nachname,$strasse,$stadt,$email,$telefon,$aufmerksam,$nachricht,$file,$submit));
        
	}
}